<div>
<div class="float-left">杯赛淘汰赛名称</div>
<div class="float-left" style="width : 400px; margin : 0 0 0 50px"><?php echo $this->cup->name?></div>
</div>


<div style="clear : both; margin : 50px 0 0 0">
<div class="float-left">球队列表 : </div>
</div>
<form action="/admin/save-cup-ko-team/cup-id/<?php echo $this->cup->id?>" method ="post">
<div style="clear : both">
<div class="table-league-team">
球队名称
</div>
<div class="table-league-team-user float-left" style="margin-left: 120px;">
用户名称
</div>
<?php $count = 0;
for($count=0 ; $count<$this->cup->team_count; $count++){
?>
<div class="table-league-team" style="clear:both;">
<input type="text" name="team_<?php echo $count +1;?>"  value="<?php echo $this->teams[$count]['team_name']?>" size="20" />
</div>
<div class="table-league-team-user float-left">
     <input type="text" name="user_<?php echo $count+1;?>" id="team_user_<?php echo $count+1;?>" value="<?php echo $this->teams[$count]['username']?>" size="20" readonly="readonly" />
</div>
    <?php if(empty($this->teams[$count]['user_id'])){?>
	<div class="table-league-team-user-choose float-left">
	    选择
	</div>
	<?php }else{?>
		<div class="table-league-team-user-delete float-left">
	    删除用户
	</div>
	<?php 	
	}?>

<?php }?>
</div>
<div style="clear : both;padding : 50px 0 0 200px;">
<input id="" class="button" type="submit" value="    确定    " />
</div>
</form>

<div id="user-input-dialog">
      no display 
</div>

<script type="text/javascript">
<!--//--><![CDATA[//><!--
jQuery.fn.center = function () {

	var top_height = ( $(window).height()-this.height() ) / 2+$(window).scrollTop();
	if(top_height<0){
		top_height=0;
	}

	this.css("top", top_height + "px");

	this.css("left", ( $(window).width()-this.width() ) / 2+$(window).scrollLeft() + "px");

	return this;

	}

	
$(document).ready(function() {
    $(".table-league-team-user-choose").each(function(){                 
  	  $(this).click(function(){
      	  $(this).addClass('chosen');

      	  var user_names=new Array(<?php echo $this->all_user_names;?>); 		      
			  var used_names_in_this_page = new Array();
			  $(".table-league-team-user").each(function(){					       
				   used_names_in_this_page.push( $(this).find('input').attr('value'));
				  
			  })  
				      
			  var all_user_ids = new Array(<?php echo $this->all_user_ids?>);				       
            var html_text = "";
            var first = true;
            var nb = 1;
            for(var name in user_names){                                   	
				if(used_names_in_this_page.indexOf(user_names[name] )==-1){

                           	  if(first){
						           first=false;
                          	   html_text += '<div class="user-radio-left"><input type="radio" name="user_ids" value = "' 
                              	             + user_names[name]  + '">' + user_names[name] +'</div>' ;
							    }else{
									   first=true;
									   html_text += '<div class="user-radio-right"><input type="radio" name="user_ids" value = "' 
			                  	             + user_names[name]  + '">' + user_names[name] +'</div>' ;
		                      }
							    if(nb++ == 10){
									   html_text +='<div style="clear : both; height: 40px" />';
									   nb = 1;
							    }
                             }
               
                      }

  				    if(html_text==""){
      				    html_text= "对不起，没有可分配的用户";
  				    }else{
      				    
      				    html_text += '<div class="choose-user-button" ><INPUT TYPE=BUTTON OnClick="chooseTeam(' 
          				              + "'" +$('.chosen').prev().find('input').attr('id') + "'" 
          				              + ');" VALUE="选择">'
            				            + '</div><div style="float: left;margin :20px 20px 20px 90px"><INPUT TYPE=BUTTON OnClick="chooseTeam()" VALUE="关闭" ></div>'
          				              ;
  				    }
  				    $('#user-input-dialog').html(html_text);
  				    $('.chosen').removeClass('chosen');
  				 
      	  
  		  $('#user-input-dialog').fadeIn();
    		$(".user-radio-left:even").addClass("bg-gray"); 
    	  	  $(".user-radio-right:odd").addClass("bg-gray"); 
    			$('#user-input-dialog').center();
        })
    });

});

function chooseTeam( id){
	var item = $(":radio:checked"); 
	var len=item.length; 
	if(len>0){ 	
		//alert($(":radio:checked").html()) ;
	  $('#' +id +'').attr('value',$(":radio:checked").val()); 
	  
	} 
	$('#user-input-dialog').hide();
	//$('.bModal').hide();

	//$('.bModal').attr('style','');

}

//--><!]]>
</script>
